<html>
<head>
<title>Craigslist Multisearch Extension</title>
<script type="text/javascript">

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons are reset to unchecked
// Function from: http://www.somacon.com/p143.php
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

// Restores select box state to saved value from localStorage.
function restore_options() {

	if( localStorage["clms_query"] ){
		document.clms_search_form.elements["clms_query"].value = localStorage["clms_query"];
	}
	
	if( localStorage["clms_catAbb"] ){
		var select = document.clms_search_form.elements["clms_catAbb"];
		for (var i = 0; i < select.children.length; i++) {
			var child = select.children[i];
			if (child.value == localStorage["clms_catAbb"]) {
				child.selected = "true";
				break;
			}
		}
	}

	if( localStorage["clms_srchType"] ){
		setCheckedValue( document.clms_search_form.elements["clms_srchType"], localStorage["clms_srchType"] );
	}

	if( localStorage["clms_minAsk"] ){
		document.clms_search_form.elements["clms_minAsk"].value = localStorage["clms_minAsk"];
	}
  
	if( localStorage["clms_maxAsk"] ){
		document.clms_search_form.elements["clms_maxAsk"].value = localStorage["clms_maxAsk"];
	}
  
	if( localStorage["clms_hasPic"] == 'true' ){
		document.clms_search_form.clms_hasPic.checked = true;
		document.clms_search_form.clms_hasPic.value = '1';
	} else {
		document.clms_search_form.clms_hasPic.checked = false;
		document.clms_search_form.clms_hasPic.value = '';
	}

}

</script>
</head>

<body onload="restore_options()">

<h3 align="center">craigslist multisearch</h3>

<div style="width: 300px; background-color: #eee; border: 1px solid #ccc; padding: 4px;">

<form action="generate_urls.html" name="clms_search_form" method="get"> 
	<table id="searchtable" cellpadding="2"> 
		<tr> 
			<td>search for: <input name="clms_query" size="30"></td>
		</tr>
		<tr>
			<td>in:
				<select name="clms_catAbb">
					<option value="ccc">all community
					<option value="eee">all event
					<option value="sss" selected>all for sale / wanted
					<option disabled value="">--
					<option value="atq"> antiques
					<option value="app"> appliances
					<option value="art"> arts &amp; crafts
					<option value="pts"> auto parts
					<option value="bab"> baby &amp; kid stuff
					<option value="bar"> barter
					<option value="bik"> bicycles
					<option value="boa"> boats
					<option value="bks"> books
					<option value="bfs"> business
					<option value="ctd"> cars &amp; trucks - by dealer
					<option value="cto"> cars &amp; trucks - by owner
					<option value="cta"> cars+trucks
					<option value="emd"> cds / dvds / vhs
					<option value="mob"> cell phones
					<option value="clo"> clothing
					<option value="clt"> collectibles
					<option value="sys"> computers &amp; tech
					<option value="ele"> electronics
					<option value="grd"> farm &amp; garden
					<option value="zip"> free stuff
					<option value="fua"> furniture
					<option value="fud"> furniture - by dealer
					<option value="fuo"> furniture - by owner
					<option value="gms"> garage sales
					<option value="for"> general
					<option value="hab"> health and beauty
					<option value="hsh"> household
					<option value="wan"> items wanted
					<option value="jwl"> jewelry
					<option value="mat"> materials
					<option value="mca"> motorcycles
					<option value="mcd"> motorcycles/scooters - by dealer
					<option value="mcy"> motorcycles/scooters - by owner
					<option value="msg"> musical instruments
					<option value="pho"> photo/video
					<option value="rvs"> recreational vehicles
					<option value="spo"> sporting goods
					<option value="tia"> tickets
					<option value="tid"> tickets - by dealer
					<option value="tix"> tickets - by owner
					<option value="tls"> tools
					<option value="tag"> toys &amp; games
					<option value="vgm"> video gaming
					<option disabled value="">--
					<option value="ggg">all gigs
					<option value="hhh">all housing
					<option value="jjj">all jobs
					<option value="ppp">all personals
					<option value="res">all resume
					<option value="bbb">all services offered
				</select> 
			</td> 
 		</tr>
 		<tr>
			<td> 
				<label><input type="radio" name="clms_srchType" value="T" title="search only posting titles" checked="checked" >title only</label> 
				<label><input type="radio" name="clms_srchType" value="A" title="search the entire posting">entire post</label> 
			</td> 
		</tr>
		<tr>
			<td>price: <input type="text" name="clms_minAsk" size="6">&nbsp;<input type="text" name="clms_maxAsk" size="6"></td>
		</tr>
		<tr>
			<td><label><input type="checkbox" name="clms_hasPic"> has image</label></td> 
		</tr> 
	</table> 
	<input type="submit" value="Search">
	<div style="float: right;"><button onclick="window.open('options.html')">Set Defaults</button></div>
</form>

</div>
</body>
</html>